package com.gnerv.business.test.service.impl;

import com.gnerv.business.test.entity.R;
import com.gnerv.business.test.service.HttpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class HttpServiceImpl implements HttpService {

    @Autowired
    RestTemplate restTemplate;

    @Override
    public void test() {
        ResponseEntity<R> forEntity = restTemplate.getForEntity("http://localhost:8060/login?account=admin&password=admin", R.class);
        System.out.println(forEntity);


        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
        HttpEntity<String> entity = new HttpEntity<String>(headers);
        ResponseEntity<R> forEntity1 =restTemplate.exchange("http://localhost:8060/platform/user/list", HttpMethod.POST, entity,R.class);

        System.out.println(forEntity1);


    }
}
